package com.uneed.api.util;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.provider.Settings;
import android.provider.Settings.System;
import android.view.View;
import java.lang.reflect.Method;

public class AndroidUtils
{
  public static String androidId(Context paramContext)
  {
    return Settings.System.getString(paramContext.getContentResolver(), "android_id");
  }

  public static boolean beforeCupcake()
  {
    if (("2".equals(Build.VERSION.SDK)) || ("1".equals(Build.VERSION.SDK)))
      return true;
    else
      return false;
  }

  public static void createShortcut(Context paramContext, String paramString, Bitmap paramBitmap, Intent paramIntent)
  {
    Intent localIntent = new Intent("com.android.launcher.action.INSTALL_SHORTCUT");
    localIntent.putExtra("android.intent.extra.shortcut.NAME", paramString);
    if (paramBitmap != null)
      localIntent.putExtra("android.intent.extra.shortcut.ICON", paramBitmap);
    localIntent.putExtra("android.intent.extra.shortcut.INTENT", paramIntent);
    paramContext.sendBroadcast(localIntent);
  }

  public static PackageInfo getPackageInfo(Context paramContext)
  {
    PackageInfo localPackageInfo = null;
	try
    {
      localPackageInfo = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0);
    }
    catch (PackageManager.NameNotFoundException localNameNotFoundException)
    {
    }
	return localPackageInfo;
  }
  
  public static SoftKeyboardController getSoftKeyboardController(View paramView)
  {
    return new SoftKeyboardHandler(paramView);
  }

  public static abstract interface SoftKeyboardController
  {
    public abstract void hide();

    public abstract void show();
  }

  private static class SoftKeyboardHandler extends Handler
    implements AndroidUtils.SoftKeyboardController
  {
    final boolean beforeCupcake = AndroidUtils.beforeCupcake();
    int count = 0;
    final View view;

    public SoftKeyboardHandler(View paramView)
    {
      this.view = paramView;
    }

    public void handleMessage(Message paramMessage)
    {
      if (this.beforeCupcake);
      Object localObject5;
        switch (paramMessage.what)
        {
        default:
          break;
        case 1:
          this.count = 0;
          removeMessages(2);
          removeMessages(4);
          sendEmptyMessageDelayed(2, 200L);
          break;
        case 2:
          if (!this.view.isShown());
        case 3:
          try
          {
        	  
/*            Object localObject1 = this.view.getContext().getSystemService("input_method");
            localObject5 = localObject1.getClass();
            Object localObject3 = new Class[2];
            localObject3[0] = View.class;
            localObject3[1] = Integer.TYPE;
            localObject5 = ((Class)localObject5).getDeclaredMethod("showSoftInput", localObject3);
            localObject3 = new Object[2];
            localObject3[0] = this.view;
            localObject3[1] = Integer.valueOf(1);
            ((Method)localObject5).invoke(localObject1, localObject3);
            int i = this.count;
            this.count = (i + 1);
            if (i > 10)
              continue;
            boolean bool = ((Boolean)localObject1.getClass().getDeclaredMethod("isActive", new Class[0]).invoke(localObject1, new Object[0])).booleanValue();
            if (bool)
              continue;
            sendEmptyMessageDelayed(2, 100L);
            this.count = 0;
            removeMessages(2);
            removeMessages(4);
            sendEmptyMessageDelayed(4, 200L);
*/
       }
          catch (Exception localException1)
          {
            localException1.printStackTrace();
          }
          break;
        case 4:
          try
          {
/*        	  
            Object localObject2 = this.view.getContext().getSystemService("input_method");
            Object localObject4 = localObject2.getClass();
            localObject5 = new Class[2];
            localObject5[0] = IBinder.class;
            localObject5[1] = Integer.TYPE;
            localObject5 = ((Class)localObject4).getDeclaredMethod("hideSoftInputFromWindow", localObject5);
            localObject4 = new Object[2];
            localObject4[0] = this.view.getWindowToken();
            localObject4[1] = Integer.valueOf(2);
            ((Method)localObject5).invoke(localObject2, localObject4);
*/
        	  }
          catch (Exception localException2)
          {
            localException2.printStackTrace();
          }
        }
      }

    @Override
    public void hide()
    {
      sendEmptyMessage(3);
    }

    @Override
    public void show()
    {
      sendEmptyMessage(1);
    }
  }
}
